import 'package:flutter/material.dart';
import 'package:flutter_mode/zjw/data_transfer/CountModel.dart';
import 'package:scoped_model/scoped_model.dart';

class ScopedUnderScreen extends StatefulWidget {
  ScopedUnderScreen({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  _ScopedUnderScreenState createState() => new _ScopedUnderScreenState();
}

class _ScopedUnderScreenState extends State<ScopedUnderScreen> {
  @override
  Widget build(BuildContext context) {
    return ScopedModelDescendant<CountModel>(builder: (context, child, model) {
      return new Scaffold(
        appBar: new AppBar(
          title: new Text(widget.title),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('You have pushed the button this many times:',
                  style: TextStyle(fontSize: 20)),
              Text('${model.count}', style: TextStyle(fontSize: 18)),
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () => model.increment(),
          tooltip: "添加",
          child: Icon(Icons.add),
        ),
      );
    });
  }

}
